#!/usr/bin/env python3

# http://www.upriss.org.uk/python/session4.html

# 2.2) Modify the program so that it asks users whether they want to
# guess again each time. Use two variables, number for the number and
# answer for the answer to the question whether they want to continue
# guessing. The program stops if the user guesses the correct number
# or answers "no". (In other words, the program continues as long as a
# user has not answered "no" and has not guessed the correct number.)

##3.1) A counter: Write a program that asks five times to guess the lucky number. Use a while loop and a counter, such as
##
##counter = 1
##while counter <= 5:
##   print "Type in the", counter, "number"
##   counter = counter +1
##
##The program asks for five guesses (no matter whether the correct
##number was guessed or not). If the correct number is guessed, the
##program outputs "Good guess!", otherwise it outputs "Try again!".
##After the fifth guess it stops and prints "Game over."

number = -1
answer = "yes"
lucky_number = 24
counter = 5
meervoud = "en"

while (number != lucky_number or answer != "stop") and counter >= 1:
    if counter == 1:
        meervoud = ""
    print("Nog {} beurt{}.".format(counter, meervoud))
    # zie http://docs.python.org/release/3.1.3/library/string.html#formatexamples
    print("Nog {c} beurt{mv}.".format(c = counter, mv = meervoud))
    counter = counter - 1
    m = input("Geef een getal of geef 'stop' om te stoppen: ")
    if (m.isdigit()):
        print("is digit: ", m)
        number = int(m)
        if number == lucky_number:
            print("lucky_number")
            break
    else:
        print("string: ", m)
        answer = m
        if answer == "stop":
            print("stop")
            break
